﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ExpressionEvaluator.Expceptions
{
	/// <summary>
	/// Exception raised on syntax error.
	/// </summary>
	public class SyntaxException : BaseException
	{
		/// <summary>
		/// Initializes a new instance of the <see cref="SyntaxExpression"/> class.
		/// </summary>
		/// <param name="message">The message.</param>
		/// <param name="codeBlock">The code block.</param>
		public SyntaxException(string message, ParserState previousState, CodeBlock codeBlock)
			: base(message + "\nPrevious state: " + previousState.ToString(), codeBlock)
		{
			PreviousState = previousState;
		}

		/// <summary>
		/// Initializes a new instance of the <see cref="SyntaxExpression"/> class.
		/// </summary>
		/// <param name="message">The message.</param>
		/// <param name="codeBlock">The code block.</param>
		/// <param name="innerException">The inner exception.</param>
		public SyntaxException(string message, ParserState previousState, CodeBlock codeBlock, Exception innerException)
			: base(message + "\nPrevious state: " + previousState.ToString(), codeBlock, innerException)
		{
			PreviousState = previousState;
		}

		public ParserState PreviousState
		{
			get;
			private set;
		}
	}
}
